<form method="POST" name="form_admin" action="<?php echo formEditAction()?>">
<input type="hidden" name="id" value="<?echo $id?>" />
<input type="hidden" name="idP" value="<?echo $filter['iCategoryId']?>" />

<table width="100%" style="padding-left:10px; line-height:2" cellpadding="2" cellspacing="0">
   <tr>
        <td width="150"><strong>Add filter for <a href="?opt=edit&id=<?echo $id?>">
			<font color="#FF0000"><?echo $category['cName']?></font></a></strong></td>
      <td> </td>
    </tr>
	<tr>
         <td><b><font color="Red"><?echo getLang('Name')?></font></b></td>         
        <td><input class="normal3" type="text" name="Name" id="Name" value="<?echo $filter['cName']?>" />
			<input type="checkbox" name="Type" value="Price" onclick="changetype(this)" 
			<?if($filter['cValue']=="Price")echo "checked='checked'"?> /> Price Filter
		</td>
    </tr>
	
	<tr>
		<td colspan="2">
			<fieldset>
			<legend>Filter Value</legend>
			
			<table width="100%" border="0" cellpadding="4" cellspacing="1"  id="tblsort">
			<tr class="headtb" nodrop="true" nodrag="true">
				<td width="5%" ><?echo getLang('Order')?></td>
				<td width="60%" >Value</td>				
				<td >Select</td>
			
			</tr>	
			</table>
			</fieldset>
		</td>
	</tr>
	
	<tr>
        <td>&nbsp;</td>
      <td> 
			<input type="button" class="b1" value="<?echo getLang('Add row')?>" onclick="addfield()">
			<input type="button" class="b1" value="Del rows selected" onclick="delrows()">
			<input type="button" onclick="location.reload(true)" class="b1"  value="<?echo getLang('Reset')?>"> 
			</td>
    </tr>
	
</table>
</form>
<script>
var isPrice=<?echo ($filter['cValue']=="Price")? "true": "false"?>;
function changetype(cb)
{
	if(cb.checked)isPrice=true;
	else isPrice=false;
	
	tblroot=getId("tblsort").tBodies[0];
	rows=tblroot.rows;
	for(i=rows.length-1;i>0;i--)
	{
		tblroot.removeChild(rows[i]);
	}
	orderrow=0;
	for(i=0;i<5;i++)
	{
		addfield();
	}
}

var orderrow=0;
function addfield(iddl,dl1,dl2)
{	
	tblroot=getId("tblsort").tBodies[0];
	var newtr=document.createElement("tr");
	newtr.className='row_'+(orderrow%2);
	var newtd=document.createElement("td");
	var input1=document.createElement("input");
	input1.className="ordertext";
	input1.id="listorder_"+orderrow;
	input1.name="listorder[]";
	input1.value=orderrow+1;
	newtd.appendChild(input1);
	newtr.appendChild(newtd);
	
	newtd=document.createElement("td");	
	newtr.appendChild(newtd);
	if(isPrice)newtd.innerHTML+="From: ";
	var in1=document.createElement("input");
	in1.name="listvalue1[]";
	in1.className='short';
	if(dl1!=undefined)in1.value=dl1;
	newtd.appendChild(in1);	
	var in2=document.createElement("input");
	in2.name="listid[]";
	in2.setAttribute("type","hidden");
	if(iddl!=undefined)in2.value=iddl;
	newtd.appendChild(in2);	
	if(isPrice)
	{
		spel=document.createElement("span");
		spel.innerHTML="&nbsp;&nbsp;&nbsp; To: ";
		newtd.appendChild(spel);
		var in3=document.createElement("input");
		in3.name="listvalue2[]";
		in3.className='short';
		if(dl2!=undefined)in3.value=dl2;
		newtd.appendChild(in3);
	}
	
	newtd=document.createElement("td");
    var newa=document.createElement("a");
	newa.innerHTML="delete";
	newa.style.cursor="pointer";
	newa.onclick=function()
	{
	   newtr.style.display='none';
       in1.value=-1;
	};
	newtd.appendChild(newa);
	newtr.appendChild(newtd);
	
	tblroot.appendChild(newtr);
	orderrow++;
	(new TableDnD).init("tblsort");	
}
<?
foreach($filterchild as $i=> $f)
{
	$value1=$f['cName'];
	if($filter['cValue']=="Price")
	{
		$arr=explode("-",$f['cName']);
		$value1=$arr[0];
		$value2=$arr[1];
	}
	echo ';addfield("'.$f['iId'].'","'.$value1.'","'.$value2.'");';
}
?>
</script>